Repetier-Firmware  1.0.0
GCode Class Reference

#include <gcode.h>

Public Member Functions

bool hasM ()
 
bool hasN ()
 
bool hasG ()
 
bool hasX ()
 
void unsetX ()
 
bool hasY ()
 
void unsetY ()
 
bool hasZ ()
 
void unsetZ ()
 
bool hasNoXYZ ()
 
bool hasE ()
 
bool hasF ()
 
bool hasT ()
 
bool hasS ()
 
bool hasP ()
 
bool isV2 ()
 
bool hasString ()
 
bool hasI ()
 
bool hasJ ()
 
bool hasR ()
 
bool hasD ()
 
bool hasC ()
 
bool hasH ()
 
bool hasA ()
 
bool hasB ()
 
bool hasK ()
 
bool hasL ()
 
bool hasO ()
 
long getS (long def)
 
long getP (long def)
 
void setFormatError ()
 
bool hasFormatError ()
 
void printCommand ()
 Print command on serial console. More...
 
bool parseBinary (uint8_t *buffer, bool fromSerial)
 
bool parseAscii (char *line, bool fromSerial)
 
void popCurrentCommand ()
 Removes the last returned command from cache. More...
 
void echoCommand ()
 

Static Public Member Functions

static GCode * peekCurrentCommand ()
 
static void readFromSerial ()
 Read from serial console or sd card. More...
 
static void pushCommand ()
 
static void executeFString (FSTRINGPARAM(cmd))
 Execute commands in progmem stored string. Multiple commands are separated by
Used to execute memory stored parts called from gcodes. For new commands use the flash sender instead. More...
 
static uint8_t computeBinarySize (char *ptr)
 Computes size of binary data from bitfield. More...
 
static void fatalError (FSTRINGPARAM(message))
 
static void reportFatalError ()
 
static void resetFatalError ()
 
static bool hasFatalError ()
 
static void keepAlive (enum FirmwareState state)
 
static FSTRINGPARAM (fatalErrorMsg)
 

Public Attributes

uint16_t N
 Line number reduced to 16 bit. More...
 
uint16_t M
 G-code M value if set. More...
 
uint16_t G
 G-code G value if set. More...
 
float X
 G-code X value if set. More...
 
float Y
 G-code Y value if set. More...
 
float Z
 G-code Z value if set. More...
 
float E
 G-code E value if set. More...
 
float F
 G-code F value if set. More...
 
int32_t S
 G-code S value if set. More...
 
int32_t P
 G-code P value if set. More...
 
float I
 G-code I value if set. More...
 
float J
 G-code J value if set. More...
 
float R
 G-code R value if set. More...
 
float D
 G-code D value if set. More...
 
float C
 G-code C value if set. More...
 
float H
 G-code H value if set. More...
 
float A
 G-code A value if set. More...
 
float B
 G-code B value if set. More...
 
float K
 G-code K value if set. More...
 
float L
 G-code L value if set. More...
 
float O
 G-code O value if set. More...
 
char * text
 Text message of g-code if present. More...
 
uint8_t T
 
bool internalCommand
 

Static Public Attributes

static uint32_t keepAliveInterval = KEEP_ALIVE_INTERVAL
 

Protected Member Functions

void debugCommandBuffer ()
 
void checkAndPushCommand ()
 
float parseFloatValue (char *s)
 
long parseLongValue (char *s)
 

Static Protected Member Functions

static void requestResend ()
 

Static Protected Attributes

static GCode commandsBuffered [GCODE_BUFFER_SIZE]
 Buffer for received commands. More...
 
static uint8_t bufferReadIndex = 0
 Read position in gcode_buffer. More...
 
static uint8_t bufferWriteIndex = 0
 Write position in gcode_buffer. More...
 
static uint8_t commandReceiving [MAX_CMD_SIZE]
 Current received command. More...
 
static uint8_t commandsReceivingWritePosition = 0
 Writing position in gcode_transbuffer. More...
 
static uint8_t sendAsBinary
 Flags the command as binary input. More...
 
static uint8_t commentDetected = false
 Flags true if we are reading the comment part of a command. More...
 
static uint8_t binaryCommandSize
 Expected size of the incoming binary command. More...
 
static bool waitUntilAllCommandsAreParsed = false
 Don't read until all commands are parsed. Needed if gcode_buffer is misused as storage for strings. More...
 
static uint32_t actLineNumber
 Line number of current command. More...
 
static volatile uint8_t bufferLength = 0
 Number of commands stored in gcode_buffer. More...
 
static uint8_t formatErrors = 0
 Number of sequential format errors. More...
 
static millis_t lastBusySignal = 0
 When was the last busy signal. More...
 
static int8_t waitingForResend
 Waiting for line to be resend. -1 = no wait. More...
 
static uint32_t lastLineNumber
 Last line number received. More...
 
static millis_t timeOfLastDataPacket
 Time, when we got the last data packet. Used to detect missing uint8_ts. More...
 
static uint8_t wasLastCommandReceivedAsBinary
 Was the last successful command in binary mode? More...
 

Private Attributes

uint16_t params
 
uint16_t params2
 

Friends

class SDCard
 
class UIDisplay
 
class GCodeSource
 

Member Function Documentation

◆ checkAndPushCommand()

void GCode::checkAndPushCommand ( )
protected

Check if result is plausible. If it is, an ok is send and the command is stored in queue. If not, a resend and ok is send.

◆ computeBinarySize()

uint8_t GCode::computeBinarySize ( char *  ptr)
static

Computes size of binary data from bitfield.

In the repetier-protocol in binary mode, the first 2 uint8_ts define the data. From this bitfield, this function computes the size of the command including the 2 uint8_ts of the bitfield and the 2 uint8_ts for the checksum.

Gcode Letter to Bit and Datatype:

  • N : Bit 0 : 16-Bit Integer
  • M : Bit 1 : 8-Bit unsigned uint8_t
  • G : Bit 2 : 8-Bit unsigned uint8_t
  • X : Bit 3 : 32-Bit Float
  • Y : Bit 4 : 32-Bit Float
  • Z : Bit 5 : 32-Bit Float
  • E : Bit 6 : 32-Bit Float
  • : Bit 7 : always set to distinguish binary from ASCII line.
  • F : Bit 8 : 32-Bit Float
  • T : Bit 9 : 8 Bit Integer
  • S : Bit 10 : 32 Bit Value
  • P : Bit 11 : 32 Bit Integer
  • V2 : Bit 12 : Version 2 command for additional commands/sizes
  • Ext : Bit 13 : There are 2 more uint8_ts following with Bits, only for future versions
  • Int :Bit 14 : Marks it as internal command,
  • Text : Bit 15 : 16 Byte ASCII String terminated with 0 Second word if V2:
  • I : Bit 0 : 32-Bit float
  • J : Bit 1 : 32-Bit float
  • R : Bit 2 : 32-Bit float
  • D : Bit 3 : 32-Bit float
  • C : Bit 4 : 32-Bit float
  • H : Bit 5 : 32-Bit float
  • A : Bit 6 : 32-Bit float
  • B : Bit 7 : 32-Bit float
  • K : Bit 8 : 32-Bit float
  • L : Bit 9 : 32-Bit float
  • O : Bit 0 : 32-Bit float

◆ debugCommandBuffer()

void GCode::debugCommandBuffer ( )
protected

◆ echoCommand()

void GCode::echoCommand ( )

◆ executeFString()

void GCode::executeFString ( FSTRINGPARAM(cmd)  )
static

Execute commands in progmem stored string. Multiple commands are separated by
Used to execute memory stored parts called from gcodes. For new commands use the flash sender instead.

◆ fatalError()

void GCode::fatalError ( FSTRINGPARAM(message)  )
static

◆ FSTRINGPARAM()

static GCode::FSTRINGPARAM ( fatalErrorMsg  )
static

◆ getP()

long GCode::getP ( long  def)
inline

◆ getS()

long GCode::getS ( long  def)
inline

◆ hasA()

bool GCode::hasA ( )
inline

◆ hasB()

bool GCode::hasB ( )
inline

◆ hasC()

bool GCode::hasC ( )
inline

◆ hasD()

bool GCode::hasD ( )
inline

◆ hasE()

bool GCode::hasE ( )
inline

◆ hasF()

bool GCode::hasF ( )
inline

◆ hasFatalError()

static bool GCode::hasFatalError ( )
inlinestatic

◆ hasFormatError()

bool GCode::hasFormatError ( )
inline

◆ hasG()

bool GCode::hasG ( )
inline

◆ hasH()

bool GCode::hasH ( )
inline

◆ hasI()

bool GCode::hasI ( )
inline

◆ hasJ()

bool GCode::hasJ ( )
inline

◆ hasK()

bool GCode::hasK ( )
inline

◆ hasL()

bool GCode::hasL ( )
inline

◆ hasM()

bool GCode::hasM ( )
inline

◆ hasN()

bool GCode::hasN ( )
inline

◆ hasNoXYZ()

bool GCode::hasNoXYZ ( )
inline

◆ hasO()

bool GCode::hasO ( )
inline

◆ hasP()

bool GCode::hasP ( )
inline

◆ hasR()

bool GCode::hasR ( )
inline

◆ hasS()

bool GCode::hasS ( )
inline

◆ hasString()

bool GCode::hasString ( )
inline

◆ hasT()

bool GCode::hasT ( )
inline

◆ hasX()

bool GCode::hasX ( )
inline

◆ hasY()

bool GCode::hasY ( )
inline

◆ hasZ()

bool GCode::hasZ ( )
inline

◆ isV2()

bool GCode::isV2 ( )
inline

◆ keepAlive()

void GCode::keepAlive ( enum FirmwareState  state)
static

◆ parseAscii()

bool GCode::parseAscii ( char *  line,
bool  fromSerial 
)

Converts a ASCII GCode line into a GCode structure.

◆ parseBinary()

bool GCode::parseBinary ( uint8_t *  buffer,
bool  fromSerial 
)

Converts a binary uint8_tfield containing one GCode line into a GCode structure. Returns true if checksum was correct.

◆ parseFloatValue()

float GCode::parseFloatValue ( char *  s)
inlineprotected

◆ parseLongValue()

long GCode::parseLongValue ( char *  s)
inlineprotected

◆ peekCurrentCommand()

GCode * GCode::peekCurrentCommand ( )
static

Get next command in command buffer. After the command is processed, call gcode_command_finished()

Get the next buffered command. Returns 0 if no more commands are buffered. For each returned command, the gcode_command_finished() function must be called.

◆ popCurrentCommand()

void GCode::popCurrentCommand ( )

Removes the last returned command from cache.

◆ printCommand()

void GCode::printCommand ( )

Print command on serial console.

◆ pushCommand()

void GCode::pushCommand ( )
static

◆ readFromSerial()

void GCode::readFromSerial ( )
static

Read from serial console or sd card.

Frees the cache used by the last command fetched.

This function is the main function to read the commands from serial console or from sd card. It must be called frequently to empty the incoming buffer.

◆ reportFatalError()

void GCode::reportFatalError ( )
static

◆ requestResend()

void GCode::requestResend ( )
staticprotected

◆ resetFatalError()

void GCode::resetFatalError ( )
static

◆ setFormatError()

void GCode::setFormatError ( )
inline

◆ unsetX()

void GCode::unsetX ( )
inline

◆ unsetY()

void GCode::unsetY ( )
inline

◆ unsetZ()

void GCode::unsetZ ( )
inline

Friends And Related Function Documentation

◆ GCodeSource

friend class GCodeSource
friend

◆ SDCard

friend class SDCard
friend

◆ UIDisplay

friend class UIDisplay
friend

Member Data Documentation

◆ A

float GCode::A

G-code A value if set.

◆ actLineNumber

uint32_t GCode::actLineNumber
staticprotected

Line number of current command.

◆ B

float GCode::B

G-code B value if set.

◆ binaryCommandSize

uint8_t GCode::binaryCommandSize
staticprotected

Expected size of the incoming binary command.

◆ bufferLength

volatile uint8_t GCode::bufferLength = 0
staticprotected

Number of commands stored in gcode_buffer.

◆ bufferReadIndex

uint8_t GCode::bufferReadIndex = 0
staticprotected

Read position in gcode_buffer.

◆ bufferWriteIndex

uint8_t GCode::bufferWriteIndex = 0
staticprotected

Write position in gcode_buffer.

◆ C

float GCode::C

G-code C value if set.

◆ commandReceiving

uint8_t GCode::commandReceiving
staticprotected

Current received command.

◆ commandsBuffered

GCode GCode::commandsBuffered
staticprotected

Buffer for received commands.

◆ commandsReceivingWritePosition

uint8_t GCode::commandsReceivingWritePosition = 0
staticprotected

Writing position in gcode_transbuffer.

◆ commentDetected

uint8_t GCode::commentDetected = false
staticprotected

Flags true if we are reading the comment part of a command.

◆ D

float GCode::D

G-code D value if set.

◆ E

float GCode::E

G-code E value if set.

◆ F

float GCode::F

G-code F value if set.

◆ formatErrors

uint8_t GCode::formatErrors = 0
staticprotected

Number of sequential format errors.

◆ G

uint16_t GCode::G

G-code G value if set.

◆ H

float GCode::H

G-code H value if set.

◆ I

float GCode::I

G-code I value if set.

◆ internalCommand

bool GCode::internalCommand

◆ J

float GCode::J

G-code J value if set.

◆ K

float GCode::K

G-code K value if set.

◆ keepAliveInterval

uint32_t GCode::keepAliveInterval = KEEP_ALIVE_INTERVAL
static

◆ L

float GCode::L

G-code L value if set.

◆ lastBusySignal

millis_t GCode::lastBusySignal = 0
staticprotected

When was the last busy signal.

◆ lastLineNumber

uint32_t GCode::lastLineNumber
staticprotected

Last line number received.

◆ M

uint16_t GCode::M

G-code M value if set.

◆ N

uint16_t GCode::N

Line number reduced to 16 bit.

◆ O

float GCode::O

G-code O value if set.

◆ P

int32_t GCode::P

G-code P value if set.

◆ params

uint16_t GCode::params
private

◆ params2

uint16_t GCode::params2
private

◆ R

float GCode::R

G-code R value if set.

◆ S

int32_t GCode::S

G-code S value if set.

◆ sendAsBinary

uint8_t GCode::sendAsBinary
staticprotected

Flags the command as binary input.

◆ T

uint8_t GCode::T

◆ text

char* GCode::text

Text message of g-code if present.

◆ timeOfLastDataPacket

millis_t GCode::timeOfLastDataPacket
staticprotected

Time, when we got the last data packet. Used to detect missing uint8_ts.

◆ waitingForResend

int8_t GCode::waitingForResend
staticprotected

Waiting for line to be resend. -1 = no wait.

◆ waitUntilAllCommandsAreParsed

bool GCode::waitUntilAllCommandsAreParsed = false
staticprotected

Don't read until all commands are parsed. Needed if gcode_buffer is misused as storage for strings.

◆ wasLastCommandReceivedAsBinary

uint8_t GCode::wasLastCommandReceivedAsBinary
staticprotected

Was the last successful command in binary mode?

◆ X

float GCode::X

G-code X value if set.

◆ Y

float GCode::Y

G-code Y value if set.

◆ Z

float GCode::Z

G-code Z value if set.


The documentation for this class was generated from the following files: